﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ManagementSystem
{
    /// <summary>
    /// 教师端窗体
    /// </summary>
    public partial class TeacherView : Form
    {
        private SystemServices service;
       
        public TeacherView()
        {
            InitializeComponent();
            service = new SystemServices();

            //获取当前时间
            label1.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            //启用计时器
            timer1.Start();
        }

        /// <summary>
        /// 退出系统操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        /// <summary>
        /// 获取学生列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 学生列表ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //获取数据库中表Student的内容
            var lst = service.GetAlls();

            //将表Student展示在DataGridView1中
            this.dataGridView1.DataSource = lst;
        }

        /// <summary>
        /// 查询学生信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 查询学生信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //打开查询窗体
            SelectStudent selectstudent = new SelectStudent();
            var result = selectstudent.ShowDialog();
        }

        /// <summary>
        /// 获取课程列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 课程列表ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //获取数据库中表Course的内容
            var lst = service.GetAllc();

            //将表Course展示在DataGridView1中
            this.dataGridView1.DataSource = lst;
        }

        /// <summary>
        /// 查询课程信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 查询课程信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //打开查询窗体
            SelectCourse selectCourse = new SelectCourse();
            var result = selectCourse.ShowDialog();
        }

        /// <summary>
        /// 获取实时时间
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer1_Tick(object sender, EventArgs e)
        {
            label1.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        }

        private void TeacherView_Load(object sender, EventArgs e)
        {

        }
    }
}
